//app.js
App({
  data: {
    //serverUrl: 'https://football.qdss.com.cn/api/'
    serverUrl: 'http://wechat-shop/wechat/'

  },

  onLaunch: function () {
    var that = this;
    

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        var url = that.data.serverUrl +"get-openid";
        wx.request({
          url: url,
          data:{code:res.code},
          success:function(rs){
            if(rs.data.status== true) {
              console.info(rs.data.data.openid);
              wx.setStorageSync('openid', rs.data.data.openid);
              that.globalData.openid = rs.data.data.openid;
            }
          }
        })
      }
    })
  

  },

  globalData: {
    userInfo: null,
    openid:'',
  }
})